﻿using System;
using Mono.Collections.Generic;

namespace Mono.Cecil
{
	// Token: 0x02000068 RID: 104
	public sealed class FieldDefinition : FieldReference, IMemberDefinition, ICustomAttributeProvider, IMetadataTokenProvider, IConstantProvider, IMarshalInfoProvider
	{
		// Token: 0x0600040C RID: 1036 RVA: 0x0001B908 File Offset: 0x00019B08
		private void ResolveLayout()
		{
			bool flag = this.offset != -2;
			if (!flag)
			{
				bool flag2 = !base.HasImage;
				if (flag2)
				{
					this.offset = -1;
				}
				else
				{
					object syncRoot = this.Module.SyncRoot;
					lock (syncRoot)
					{
						bool flag4 = this.offset != -2;
						if (!flag4)
						{
							this.offset = this.Module.Read<FieldDefinition, int>(this, (FieldDefinition field, MetadataReader reader) => reader.ReadFieldLayout(field));
						}
					}
				}
			}
		}

		// Token: 0x17000094 RID: 148
		// (get) Token: 0x0600040D RID: 1037 RVA: 0x0001B9C0 File Offset: 0x00019BC0
		public bool HasLayoutInfo
		{
			get
			{
				bool flag = this.offset >= 0;
				bool result;
				if (flag)
				{
					result = true;
				}
				else
				{
					this.ResolveLayout();
					result = (this.offset >= 0);
				}
				return result;
			}
		}

		// Token: 0x17000095 RID: 149
		// (get) Token: 0x0600040E RID: 1038 RVA: 0x0001B9FC File Offset: 0x00019BFC
		// (set) Token: 0x0600040F RID: 1039 RVA: 0x000038B2 File Offset: 0x00001AB2
		public int Offset
		{
			get
			{
				bool flag = this.offset >= 0;
				int result;
				if (flag)
				{
					result = this.offset;
				}
				else
				{
					this.ResolveLayout();
					result = ((this.offset >= 0) ? this.offset : -1);
				}
				return result;
			}
			set
			{
				this.offset = value;
			}
		}

		// Token: 0x17000096 RID: 150
		// (get) Token: 0x06000410 RID: 1040 RVA: 0x0001BA40 File Offset: 0x00019C40
		// (set) Token: 0x06000411 RID: 1041 RVA: 0x000038BC File Offset: 0x00001ABC
		internal FieldDefinitionProjection WindowsRuntimeProjection
		{
			get
			{
				return (FieldDefinitionProjection)this.projection;
			}
			set
			{
				this.projection = value;
			}
		}

		// Token: 0x06000412 RID: 1042 RVA: 0x0001BA60 File Offset: 0x00019C60
		private void ResolveRVA()
		{
			bool flag = this.rva != -2;
			if (!flag)
			{
				bool flag2 = !base.HasImage;
				if (!flag2)
				{
					object syncRoot = this.Module.SyncRoot;
					lock (syncRoot)
					{
						bool flag4 = this.rva != -2;
						if (!flag4)
						{
							this.rva = this.Module.Read<FieldDefinition, int>(this, (FieldDefinition field, MetadataReader reader) => reader.ReadFieldRVA(field));
						}
					}
				}
			}
		}

		// Token: 0x17000097 RID: 151
		// (get) Token: 0x06000413 RID: 1043 RVA: 0x0001BB0C File Offset: 0x00019D0C
		public int RVA
		{
			get
			{
				bool flag = this.rva > 0;
				int result;
				if (flag)
				{
					result = this.rva;
				}
				else
				{
					this.ResolveRVA();
					result = ((this.rva > 0) ? this.rva : 0);
				}
				return result;
			}
		}

		// Token: 0x17000098 RID: 152
		// (get) Token: 0x06000414 RID: 1044 RVA: 0x0001BB50 File Offset: 0x00019D50
		// (set) Token: 0x06000415 RID: 1045 RVA: 0x000038C6 File Offset: 0x00001AC6
		public byte[] InitialValue
		{
			get
			{
				bool flag = this.initial_value != null;
				byte[] result;
				if (flag)
				{
					result = this.initial_value;
				}
				else
				{
					this.ResolveRVA();
					bool flag2 = this.initial_value == null;
					if (flag2)
					{
						this.initial_value = Empty<byte>.Array;
					}
					result = this.initial_value;
				}
				return result;
			}
			set
			{
				this.initial_value = value;
				this.HasFieldRVA = !this.initial_value.IsNullOrEmpty<byte>();
				this.rva = 0;
			}
		}

		// Token: 0x17000099 RID: 153
		// (get) Token: 0x06000416 RID: 1046 RVA: 0x0001BBA0 File Offset: 0x00019DA0
		// (set) Token: 0x06000417 RID: 1047 RVA: 0x0001BBB8 File Offset: 0x00019DB8
		public FieldAttributes Attributes
		{
			get
			{
				return (FieldAttributes)this.attributes;
			}
			set
			{
				bool flag = base.IsWindowsRuntimeProjection && value != (FieldAttributes)this.attributes;
				if (flag)
				{
					throw new InvalidOperationException();
				}
				this.attributes = (ushort)value;
			}
		}

		// Token: 0x1700009A RID: 154
		// (get) Token: 0x06000418 RID: 1048 RVA: 0x0001BBF0 File Offset: 0x00019DF0
		// (set) Token: 0x06000419 RID: 1049 RVA: 0x0001BC28 File Offset: 0x00019E28
		public bool HasConstant
		{
			get
			{
				this.ResolveConstant(ref this.constant, this.Module);
				return this.constant != Mixin.NoValue;
			}
			set
			{
				bool flag = !value;
				if (flag)
				{
					this.constant = Mixin.NoValue;
				}
			}
		}

		// Token: 0x1700009B RID: 155
		// (get) Token: 0x0600041A RID: 1050 RVA: 0x0001BC4C File Offset: 0x00019E4C
		// (set) Token: 0x0600041B RID: 1051 RVA: 0x000038EC File Offset: 0x00001AEC
		public object Constant
		{
			get
			{
				return this.HasConstant ? this.constant : null;
			}
			set
			{
				this.constant = value;
			}
		}

		// Token: 0x1700009C RID: 156
		// (get) Token: 0x0600041C RID: 1052 RVA: 0x0001BC70 File Offset: 0x00019E70
		public bool HasCustomAttributes
		{
			get
			{
				bool flag = this.custom_attributes != null;
				bool result;
				if (flag)
				{
					result = (this.custom_attributes.Count > 0);
				}
				else
				{
					result = this.GetHasCustomAttributes(this.Module);
				}
				return result;
			}
		}

		// Token: 0x1700009D RID: 157
		// (get) Token: 0x0600041D RID: 1053 RVA: 0x0001BCAC File Offset: 0x00019EAC
		public Collection<CustomAttribute> CustomAttributes
		{
			get
			{
				return this.custom_attributes ?? this.GetCustomAttributes(ref this.custom_attributes, this.Module);
			}
		}

		// Token: 0x1700009E RID: 158
		// (get) Token: 0x0600041E RID: 1054 RVA: 0x0001BCDC File Offset: 0x00019EDC
		public bool HasMarshalInfo
		{
			get
			{
				bool flag = this.marshal_info != null;
				return flag || this.GetHasMarshalInfo(this.Module);
			}
		}

		// Token: 0x1700009F RID: 159
		// (get) Token: 0x0600041F RID: 1055 RVA: 0x0001BD0C File Offset: 0x00019F0C
		// (set) Token: 0x06000420 RID: 1056 RVA: 0x000038F6 File Offset: 0x00001AF6
		public MarshalInfo MarshalInfo
		{
			get
			{
				return this.marshal_info ?? this.GetMarshalInfo(ref this.marshal_info, this.Module);
			}
			set
			{
				this.marshal_info = value;
			}
		}

		// Token: 0x170000A0 RID: 160
		// (get) Token: 0x06000421 RID: 1057 RVA: 0x0001BD3C File Offset: 0x00019F3C
		// (set) Token: 0x06000422 RID: 1058 RVA: 0x00003900 File Offset: 0x00001B00
		public bool IsCompilerControlled
		{
			get
			{
				return this.attributes.GetMaskedAttributes(7, 0U);
			}
			set
			{
				this.attributes = this.attributes.SetMaskedAttributes(7, 0U, value);
			}
		}

		// Token: 0x170000A1 RID: 161
		// (get) Token: 0x06000423 RID: 1059 RVA: 0x0001BD5C File Offset: 0x00019F5C
		// (set) Token: 0x06000424 RID: 1060 RVA: 0x00003917 File Offset: 0x00001B17
		public bool IsPrivate
		{
			get
			{
				return this.attributes.GetMaskedAttributes(7, 1U);
			}
			set
			{
				this.attributes = this.attributes.SetMaskedAttributes(7, 1U, value);
			}
		}

		// Token: 0x170000A2 RID: 162
		// (get) Token: 0x06000425 RID: 1061 RVA: 0x0001BD7C File Offset: 0x00019F7C
		// (set) Token: 0x06000426 RID: 1062 RVA: 0x0000392E File Offset: 0x00001B2E
		public bool IsFamilyAndAssembly
		{
			get
			{
				return this.attributes.GetMaskedAttributes(7, 2U);
			}
			set
			{
				this.attributes = this.attributes.SetMaskedAttributes(7, 2U, value);
			}
		}

		// Token: 0x170000A3 RID: 163
		// (get) Token: 0x06000427 RID: 1063 RVA: 0x0001BD9C File Offset: 0x00019F9C
		// (set) Token: 0x06000428 RID: 1064 RVA: 0x00003945 File Offset: 0x00001B45
		public bool IsAssembly
		{
			get
			{
				return this.attributes.GetMaskedAttributes(7, 3U);
			}
			set
			{
				this.attributes = this.attributes.SetMaskedAttributes(7, 3U, value);
			}
		}

		// Token: 0x170000A4 RID: 164
		// (get) Token: 0x06000429 RID: 1065 RVA: 0x0001BDBC File Offset: 0x00019FBC
		// (set) Token: 0x0600042A RID: 1066 RVA: 0x0000395C File Offset: 0x00001B5C
		public bool IsFamily
		{
			get
			{
				return this.attributes.GetMaskedAttributes(7, 4U);
			}
			set
			{
				this.attributes = this.attributes.SetMaskedAttributes(7, 4U, value);
			}
		}

		// Token: 0x170000A5 RID: 165
		// (get) Token: 0x0600042B RID: 1067 RVA: 0x0001BDDC File Offset: 0x00019FDC
		// (set) Token: 0x0600042C RID: 1068 RVA: 0x00003973 File Offset: 0x00001B73
		public bool IsFamilyOrAssembly
		{
			get
			{
				return this.attributes.GetMaskedAttributes(7, 5U);
			}
			set
			{
				this.attributes = this.attributes.SetMaskedAttributes(7, 5U, value);
			}
		}

		// Token: 0x170000A6 RID: 166
		// (get) Token: 0x0600042D RID: 1069 RVA: 0x0001BDFC File Offset: 0x00019FFC
		// (set) Token: 0x0600042E RID: 1070 RVA: 0x0000398A File Offset: 0x00001B8A
		public bool IsPublic
		{
			get
			{
				return this.attributes.GetMaskedAttributes(7, 6U);
			}
			set
			{
				this.attributes = this.attributes.SetMaskedAttributes(7, 6U, value);
			}
		}

		// Token: 0x170000A7 RID: 167
		// (get) Token: 0x0600042F RID: 1071 RVA: 0x0001BE1C File Offset: 0x0001A01C
		// (set) Token: 0x06000430 RID: 1072 RVA: 0x000039A1 File Offset: 0x00001BA1
		public bool IsStatic
		{
			get
			{
				return this.attributes.GetAttributes(16);
			}
			set
			{
				this.attributes = this.attributes.SetAttributes(16, value);
			}
		}

		// Token: 0x170000A8 RID: 168
		// (get) Token: 0x06000431 RID: 1073 RVA: 0x0001BE3C File Offset: 0x0001A03C
		// (set) Token: 0x06000432 RID: 1074 RVA: 0x000039B8 File Offset: 0x00001BB8
		public bool IsInitOnly
		{
			get
			{
				return this.attributes.GetAttributes(32);
			}
			set
			{
				this.attributes = this.attributes.SetAttributes(32, value);
			}
		}

		// Token: 0x170000A9 RID: 169
		// (get) Token: 0x06000433 RID: 1075 RVA: 0x0001BE5C File Offset: 0x0001A05C
		// (set) Token: 0x06000434 RID: 1076 RVA: 0x000039CF File Offset: 0x00001BCF
		public bool IsLiteral
		{
			get
			{
				return this.attributes.GetAttributes(64);
			}
			set
			{
				this.attributes = this.attributes.SetAttributes(64, value);
			}
		}

		// Token: 0x170000AA RID: 170
		// (get) Token: 0x06000435 RID: 1077 RVA: 0x0001BE7C File Offset: 0x0001A07C
		// (set) Token: 0x06000436 RID: 1078 RVA: 0x000039E6 File Offset: 0x00001BE6
		public bool IsNotSerialized
		{
			get
			{
				return this.attributes.GetAttributes(128);
			}
			set
			{
				this.attributes = this.attributes.SetAttributes(128, value);
			}
		}

		// Token: 0x170000AB RID: 171
		// (get) Token: 0x06000437 RID: 1079 RVA: 0x0001BEA0 File Offset: 0x0001A0A0
		// (set) Token: 0x06000438 RID: 1080 RVA: 0x00003A00 File Offset: 0x00001C00
		public bool IsSpecialName
		{
			get
			{
				return this.attributes.GetAttributes(512);
			}
			set
			{
				this.attributes = this.attributes.SetAttributes(512, value);
			}
		}

		// Token: 0x170000AC RID: 172
		// (get) Token: 0x06000439 RID: 1081 RVA: 0x0001BEC4 File Offset: 0x0001A0C4
		// (set) Token: 0x0600043A RID: 1082 RVA: 0x00003A1A File Offset: 0x00001C1A
		public bool IsPInvokeImpl
		{
			get
			{
				return this.attributes.GetAttributes(8192);
			}
			set
			{
				this.attributes = this.attributes.SetAttributes(8192, value);
			}
		}

		// Token: 0x170000AD RID: 173
		// (get) Token: 0x0600043B RID: 1083 RVA: 0x0001BEE8 File Offset: 0x0001A0E8
		// (set) Token: 0x0600043C RID: 1084 RVA: 0x00003A34 File Offset: 0x00001C34
		public bool IsRuntimeSpecialName
		{
			get
			{
				return this.attributes.GetAttributes(1024);
			}
			set
			{
				this.attributes = this.attributes.SetAttributes(1024, value);
			}
		}

		// Token: 0x170000AE RID: 174
		// (get) Token: 0x0600043D RID: 1085 RVA: 0x0001BF0C File Offset: 0x0001A10C
		// (set) Token: 0x0600043E RID: 1086 RVA: 0x00003A4E File Offset: 0x00001C4E
		public bool HasDefault
		{
			get
			{
				return this.attributes.GetAttributes(32768);
			}
			set
			{
				this.attributes = this.attributes.SetAttributes(32768, value);
			}
		}

		// Token: 0x170000AF RID: 175
		// (get) Token: 0x0600043F RID: 1087 RVA: 0x0001BF30 File Offset: 0x0001A130
		// (set) Token: 0x06000440 RID: 1088 RVA: 0x00003A68 File Offset: 0x00001C68
		public bool HasFieldRVA
		{
			get
			{
				return this.attributes.GetAttributes(256);
			}
			set
			{
				this.attributes = this.attributes.SetAttributes(256, value);
			}
		}

		// Token: 0x170000B0 RID: 176
		// (get) Token: 0x06000441 RID: 1089 RVA: 0x0000A3A0 File Offset: 0x000085A0
		public override bool IsDefinition
		{
			get
			{
				return true;
			}
		}

		// Token: 0x170000B1 RID: 177
		// (get) Token: 0x06000442 RID: 1090 RVA: 0x0001B280 File Offset: 0x00019480
		// (set) Token: 0x06000443 RID: 1091 RVA: 0x00003571 File Offset: 0x00001771
		public new TypeDefinition DeclaringType
		{
			get
			{
				return (TypeDefinition)base.DeclaringType;
			}
			set
			{
				base.DeclaringType = value;
			}
		}

		// Token: 0x06000444 RID: 1092 RVA: 0x00003A82 File Offset: 0x00001C82
		public FieldDefinition(string name, FieldAttributes attributes, TypeReference fieldType) : base(name, fieldType)
		{
			this.attributes = (ushort)attributes;
		}

		// Token: 0x06000445 RID: 1093 RVA: 0x0001BF54 File Offset: 0x0001A154
		public override FieldDefinition Resolve()
		{
			return this;
		}

		// Token: 0x04000112 RID: 274
		private ushort attributes;

		// Token: 0x04000113 RID: 275
		private Collection<CustomAttribute> custom_attributes;

		// Token: 0x04000114 RID: 276
		private int offset = -2;

		// Token: 0x04000115 RID: 277
		internal int rva = -2;

		// Token: 0x04000116 RID: 278
		private byte[] initial_value;

		// Token: 0x04000117 RID: 279
		private object constant = Mixin.NotResolved;

		// Token: 0x04000118 RID: 280
		private MarshalInfo marshal_info;
	}
}
